﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using notepadplus.Classes.TabManager;
using notepadplus;

namespace notepadplus.Dialogs.NewDocument
{
    public partial class NdWindow : Form
    {
        public NdWindow()
        {
            InitializeComponent();
        }

        private void NdWindow_Load(object sender, EventArgs e)
        {
            documentName.Text = Properties.Settings.Default.settableResource;
        }

        private void resourceBrowser_Click(object sender, EventArgs e)
        {
            ResourceBrowser resbrow = new ResourceBrowser();
            resbrow.Show(this);
        }

        private void folderBrowser_Click(object sender, EventArgs e)
        {
            DialogResult diares = folderBrowserDig.ShowDialog();
            if (diares.Equals(DialogResult.OK))
            {
                savePathName.Text = folderBrowserDig.SelectedPath;
            }
        }

        private void savelaterCheck_CheckedChanged(object sender, EventArgs e)
        {
            if (savelaterCheck.Checked == true)
            {
                groupBox1.Enabled = false;
            }
            else
            {
                //
            }
        }

        private void savedirectCheck_CheckedChanged(object sender, EventArgs e)
        {
            if (savedirectCheck.Checked == true)
            {
                groupBox1.Enabled = true;
            }
            else
            {
                //
            }
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            if (savedirectCheck.Checked == true)
            {
                if (savePathName.Text == "")
                {
                    MessageBox.Show("Please enter a path!", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    try
                    {
                        System.IO.File.Create(savePathName.Text + documentName + extensionName);
                        // TODO: create new tab with content of document
                    }
                    catch
                    {
                        MessageBox.Show("ERROR: invalid path!");
                    }
                }
            }
            else
            {
                // TODO: add new tab
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            MessageBox.Show(this, "Do you know that you can set standard for creating a new document? Goto 'Preferences' and then click onto 'Settings...', then navigate to the 'New Document'-Tab and edit the standards.", "Editor++", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}
